/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Monitores;

/**
 *
 * @author 21322325
 */
public class Hilo extends Thread{
    public Monitor m1;
    public String id;
    
    public Hilo (Monitor m1, String id) {
        this.m1 = m1;
        this.id = id;
        System.out.println("Constructor Hilo " + this.id);
    }
    
    public void run () {
        while (true) {
            try{
                System.out.println("Hilo " + this.id + ", me duermo un 1sg");
                Thread.sleep(1000);
                System.out.println("Cagonto!! : " + this.id + ", quiero entrar en el monitor." );
                try{
                    m1.entrar(this.id);
                } catch (Exception e){
                    e.printStackTrace();
                }
            }catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
